function setpath(fname, opt)
if nargin < 1
    fname = 'path.mat';
end
if nargin < 2
    opt = '';
end
if strcmpi(opt,'-o') %overwrite
    delete(fname);
end

if (exist(fname, 'file') == 0)
    p__path = path();
    path(p__path, [genpath(cd('.')), genpath(cd(cd(['..',filesep,'tools'])))]);
    disp(['saving to ',fname]);
    save(fname, 'p__path');
    %setPrompt('timestamp');
else
    warning('setpath already done. call "resetpath" first');
end
end